﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MyQQListView;
using MyQQListView.Enum;
using Lyh.MyQQListView.Enum;
using Lyh.MyQQListView.Util;

namespace MyTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            qqListView1.Clear();

            List<Group> groups = new List<Group>();
            Friend friend = new Friend()
            {
                Description = "Andy Lau",
                GroupID = 1,
                HeadImage = "big1",
                IsSysHead = false,
                NikeName = "刘德华",
                UserState = UserState.Online,
                Uin = 1122
            };
            Friend friend2 = new Friend()
            {
                Description = "高兴就要笑，超级搞笑",
                GroupID = 1,
                HeadImage = "xxx",
                IsSysHead = false,
                NikeName = "周星星",
                UserState = UserState.Offline,
                Uin = 3344
            };
            Friend friend3 = new Friend()
            {
                Description = "谢谢大家支持我哦",
                GroupID = 1,
                HeadImage = "liut",
                IsSysHead = false,
                NikeName = "刘亦菲",
                UserState = UserState.Offline,
                Uin = 5566
            };
            Friend friend4 = new Friend()
            {
                Description = "牛牛~",
                GroupID = 2,
                HeadImage = "niu",
                IsSysHead = false,
                NikeName = "阿牛",
                UserState = UserState.Online,
                Uin = 7788
            };
            IList<Friend> arr = new List<Friend>();
            arr.Add(friend);
            arr.Add(friend2);
            arr.Add(friend3);
            IList<Friend> arr2 = new List<Friend>();
            arr2.Add(friend4);
            Group group = new Group()
            {
                //FriendCount = 3,
                Id = 1,
                Friends = arr,
                OnlineFriendCount = 0,
                Title = "我的同学"
            };
            Group group2 = new Group()
            {
                //FriendCount = 0,
                UserOrder = UserOrder.NickName,
                Id = 2,
                Friends = arr2,
                OnlineFriendCount = 0,
                Title = "我的网友"
            };

            groups.Add(group);
            groups.Add(group2);

            //qqListView1.IsTransparent = true;
            qqListView1.InitFriendList(groups);
        }

        private void 小图标ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            qqListView1.HeadImageMode = HeadImageMode.Small;
            Form1_Load(sender, e);
        }

        private void 标准图标ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            qqListView1.HeadImageMode = HeadImageMode.Normal;
            Form1_Load(sender, e);
        }

        private void 大头像ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            qqListView1.HeadImageMode = HeadImageMode.Large;
            Form1_Load(sender, e);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            qqListView1.SelectFriend(1122);
            MessageBox.Show("test");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //Point p = button1.PointToScreen(new Point(0, 0));

            //MouseHelper.AutoClick(p.X+button1.Width/2, p.Y+button1.Height/2);

            //MouseHelper.AutoClick(button1);
        }

        private void qqListView1_SelectedFriendChanged(object sender, EventArgs e)
        {
            Friend f=sender as Friend;
            MessageBox.Show("您选择了" + f.NikeName);
        }

        private void button2_Click_1(object sender, EventArgs e)
        {

            richTextBox1.Clear();

            richTextBox1.SelectionFont = new Font("隶书", 18, System.Drawing.FontStyle.Italic);
            richTextBox1.SelectionColor = Color.FromArgb(0, 128, 64);
            richTextBox1.SelectedText = "窗体的使用说明：" + "\n";

            richTextBox1.SelectionFont = new Font("隶书", 18, System.Drawing.FontStyle.Italic);
            richTextBox1.SelectionColor = Color.Green;
            richTextBox1.SelectedText = "窗体的使用说明：" + "\n";

            richTextBox1.SelectionBullet = true;
            richTextBox1.SelectionFont = new Font("微软雅黑", 12, System.Drawing.FontStyle.Bold);
            richTextBox1.SelectionColor = Color.FromArgb(0,0,255);
            richTextBox1.SelectedText = "朦朦兔  20:15:26 读入的RTF文件为 微软雅黑\n";
            richTextBox1.SelectionBullet = true;

            richTextBox1.SelectionFont = new Font("仿宋", 12, System.Drawing.FontStyle.Bold);
            richTextBox1.SelectionColor = Color.Blue;
            richTextBox1.SelectedText = "朦朦兔  20:15:26  仿宋\n";

            richTextBox1.SelectionFont = new Font("宋体", 10, System.Drawing.FontStyle.Bold);
            richTextBox1.SelectionColor = Color.Blue;
            richTextBox1.SelectedText = "~~ 朦朦兔  20:15:26 \n";

            richTextBox1.SelectionFont = new Font("隶书", 14, System.Drawing.FontStyle.Bold);
            //BlueViolet 蓝紫色
            richTextBox1.SelectionColor = Color.BlueViolet;
            richTextBox1.SelectedText = "可以使用锁定功能保护文本中的关键字符，以免被错误地修改\n";

            richTextBox1.SelectionFont = new Font("隶书", 14, System.Drawing.FontStyle.Bold);
            //紫色
            richTextBox1.SelectionColor = Color.Purple;
            richTextBox1.SelectedText = "可以使用替换功能修改文本中的某些内容，或直接修改。\n";
            richTextBox1.SelectionBullet = false;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            EmotionDropdown d = new EmotionDropdown();
            d.EmotionContainer.ItemClick += new Lyh.QQEmotionPanel.EmotionItemMouseEventHandler(EmotionContainer_ItemClick);
            d.Show(button3);
        }

        void EmotionContainer_ItemClick(object sender, Lyh.QQEmotionPanel.EmotionItemMouseClickEventArgs e)
        {
            gifBox1.Image = e.Item.Image;
            pictureBox1.Image = e.Item.Image;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            new Form2().Show();
        }
    }
}
